<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		
		<input type="text" id="username" name="username" placeholder="用户名" />
		
		<hr />
		<!--方法三：check方法需要返回-->
		<form action="" id="fsubmit" onsubmit="return check()">
			<input type="text" name="uname" id="uname" />
			<input type="submit" id="" value="提交" />
		</form>
		
		<script type="text/javascript">
			document.getElementById("username").onblur = function(){
				alert("失去焦点");
			}
			document.getElementById("username").onfocus = function(){
				//alert("我来了！！");
			}
			document.getElementById("username").onmouseover = function(){
				alert("......");
			}
			
			//如果没有返回值或者返回true，则会提交表单，返回false则表单被阻止提交
			
			/*方法一：
			 * document.getElementById("fsubmit").onsubmit = function(){
				var flag = true;
				return false;
			}*/
			/*方法二：
			 * document.getElementById("fsubmit").onclick = function(){
				var flag = true;
				return true;
			}
			*/
			function check(){
				return false;
			}
		</script>
	</body>
</html>
